import {Component, OnInit} from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd/message';
import {HttpClient} from '@angular/common/http';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';


@Component({
  selector: 'app-demo',
  templateUrl: './demo.component.html',
  styleUrls: ['./demo.component.css']
})
export class DemoComponent implements OnInit {

  validateForm!: FormGroup;


  loading = false;
  color = 0;
  myBorder = 'has-border';
  data = [
    {
      title: 'Title 1'
    },
    {
      title: 'Title 2'
    },
    {
      title: 'Title 3'
    },
    {
      title: 'Title 4'
    }
  ];
  classCheckObj = {
    'inner-box': this.color === 0,
    'red-info': this.color === 1,
  };

  constructor(private http: HttpClient,
              private  fb: FormBuilder
  ) {
  }


  ngOnInit(): void {
    this.validateForm = this.fb.group({
      userName: [null, [Validators.required]]
    });
  }

  getData(): void {
    // 返回值必须是json
    const api = '/api/test'; // 这里是你请求的接口
    this.http.get(api).subscribe((response: any) => {
      console.log(response);
    });

  }
}
